package cn.com.thinker.gen.create;

import cn.com.thinker.gen.create.service.IProjectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationStartingEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.Order;

/**
 * Created by crazyHC on 2017/6/13.
 * 指定配置文件 java -jar thinGen-1.0-SNAPSHOT.jar --spring.config.location=application.yml,test.yml
 */
@Order(value = 1) @Slf4j
@SpringBootApplication
public class ThinGenApplication implements CommandLineRunner, ApplicationListener<ApplicationStartingEvent> {

    @Autowired
    private IProjectService projectService;

    public static void main(String[] args) {

        SpringApplication application = new SpringApplication(ThinGenApplication.class);
//        application.addListeners(new ThinGenApplication());
        application.run(args);
    }

    @Override
    public void run(String... args) throws Exception {
        log.info(">>>>>>>>>>>>>>>服务启动时执行，CommandLineRunner::run <<<<<<<<<<<<<");
        projectService.build();
    }


    @Override
    public void onApplicationEvent(ApplicationStartingEvent event) {
        System.out.println(">>>>>>>>>>>>>>>服务启动前执行，ApplicationListener::onApplicationEvent <<<<<<<<<<<<<");
    }
}
